package com.woniu.service.vo;

import com.woniu.entity.TestDetail;
import com.woniu.entity.TestOutside;
import com.woniu.entity.TestType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;

import java.util.Comparator;
import java.util.Date;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class TestVo {
    private String testCode;

    private String testName;

    private String introduce;

    private String courseUrl;

    private String testUrl;

    private String difficulty;
    private Integer difficult;
    private String flag;

    private String testType;
    private Integer testTypeId;

    private String testPictureUrl;
    private Integer[] testTypeArray;

    private String simpleNote;

    private Integer usedNumber;

    private Integer visitors;

    private Date collectTime;

    /**
     * 将TestDetail和TestOutside的属性赋值给TestVo
     *
     * @param testDetail 编码-名字-介绍-课程url-试题url-标志
     * @param testVo
     * @return
     */
    public TestVo testDetailToTestVo(TestDetail testDetail, TestVo testVo) {
        testVo.testCode = testDetail.getTestCode().toString();
        testVo.testName = testDetail.getTestName();
        testVo.introduce = testDetail.getIntroduce();
        testVo.courseUrl = testDetail.getCourseUrl();
        testVo.testUrl = testDetail.getTestUrl();
        testVo.flag = testDetail.getFlag();
        testVo.simpleNote = testDetail.getTestNote();
        return testVo;
    }

    /**
     * 将TestDetail和TestOutside的属性赋值给TestVo
     *
     * @param testOutside 图片url-使用次数
     * @param testVo
     * @return
     */
    public TestVo testOutsideToTestVo(TestOutside testOutside, TestVo testVo) {
        testVo.testPictureUrl = testOutside.getTestPictureUrl();
        testVo.usedNumber = testOutside.getUserdNumbers();
        if (testOutside.getDifficultyScore() == 5) {
            testVo.difficulty = "初级";
        } else if (testOutside.getDifficultyScore() == 10) {
            testVo.difficulty = "中级";
        } else if (testOutside.getDifficultyScore() == 15) {
            testVo.difficulty = "高级";
        }

        return testVo;
    }

    /**
     * 靶场名称、靶场图片、访问人数、文件类型
     *
     * @param testOutside
     * @param testType
     * @return
     */
    public TestVo testInfo(TestOutside testOutside, TestType testType) {
        TestVo testVo = new TestVo();
        testVo.testCode = testOutside.getTestCode().toString();
        testVo.testName = testOutside.getTestName();
        testVo.testPictureUrl = testOutside.getTestPictureUrl();
        testVo.visitors = testOutside.getVisitors();
        testVo.testType = testType.getTypeName();
        return testVo;
    }

}
